cmake_minimum_required(VERSION 3.10)
add_definitions(-DUNICODE -D_UNICODE)

project(cmakedemo1)

message(STATUS "CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
    message(STATUS "aarch64")
else()
    message(STATUS "using x86_64")
endif()

# demo use add_custom_command
set(TEST_FILE "hello_log.txt")
add_custom_command(OUTPUT ${TEST_FILE}
    COMMAND echo "Generating log.txt file..."
    COMMENT "This is a test"
)

add_custom_target(Test1 ALL DEPENDS ${TEST_FILE})

add_custom_command(TARGET Test1 PRE_BUILD
    COMMAND echo "executing a fake command"
    COMMAND ${CMAKE_COMMAND} -E copy  ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE}
    COMMENT "This command will be executed before building target Test1"
)

set(COPYITEM test1)

add_custom_command(OUTPUT COPY_RES
  COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${COPYITEM} ${CMAKE_CURRENT_BINARY_DIR}/${COPYITEM}
 )

add_custom_target(CopyTask ALL DEPENDS COPY_RES)
